﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;

[TestClass]
public class ReverseEgnTest
{
    private const string INPUT_FILE_NAME = @"..\..\..\ReverseEgn\persons.txt";
    [TestMethod]
    public void MainTest()
    {
        File.Delete(INPUT_FILE_NAME);
        StreamWriter testFile = new StreamWriter(INPUT_FILE_NAME);
        string sampleText = @"I am Bay Ivan. My Bulgarian personal ID number (EGN) is 4806182906. My phone number is 0888 / 12-34-56. I have 2 sons.
Peter is the oldest. His EGN is: 6203120707. The other is Ivan and his EGN is 6711287769. My credit card number is 4716315223269910.";
        using (testFile)
        {
            testFile.Write(sampleText);
        }
        string expectedText = @"I am Bay Ivan. My Bulgarian personal ID number (EGN) is 6092816084. My phone number is 0888 / 12-34-56. I have 2 sons.
Peter is the oldest. His EGN is: 7070213026. The other is Ivan and his EGN is 9677821176. My credit card number is 4716315223269910.
";
        ReverseEgn.Main();
        StreamReader sr = new StreamReader(INPUT_FILE_NAME);
        string actualText;
        using (sr)
        {
            actualText = sr.ReadToEnd();
        }
        Assert.AreEqual(expectedText, actualText);
    }

    [TestMethod]
    public void SampleTest()
    {
        File.Delete(INPUT_FILE_NAME);
        StreamWriter testFile = new StreamWriter(INPUT_FILE_NAME);
        string sampleText = @"I am Bay Ivan. My EGN is 4806182906. My phone number is 0888 / 12-34-56. My son's EGN is: 6203120707. My VISA card number is 4716 3152 2326 9910.";
        using (testFile)
        {
            testFile.Write(sampleText);
        }
        string expectedText = @"I am Bay Ivan. My EGN is 6092816084. My phone number is 0888 / 12-34-56. My son's EGN is: 7070213026. My VISA card number is 4716 3152 2326 9910.
";
        ReverseEgn.Main();
        StreamReader sr = new StreamReader(INPUT_FILE_NAME);
        string actualText;
        using (sr)
        {
            actualText = sr.ReadToEnd();
        }
        Assert.AreEqual(expectedText, actualText);
    }
}
